#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#define LOG "log.txt"
#define ERROR "error.txt"
#define OUT "out.txt"
int main()
{

write(1,"hello write\n",12);
printf("hello world\n");
fork();
/*int fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
dup2(fd,1);
printf("I am printf\n");
fprintf(stdout,"I am fprintf->stdout\n");
fprintf(stderr,"I am fprintf->stderr\n");*/
/*close(1);
int fd=open(ERROR,O_WRONLY|O_CREAT|O_APPEND,0666);
printf("This is  the result of the process\n");
close(2);
fd=open(OUT,O_WRONLY|O_CREAT|O_APPEND,0666);
fprintf(stderr,"This is the error of the process\n");
*/



 /* close(1);
int fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
fprintf(stdout,"stdout\n");
fprintf(stderr,"stderr\n");
*/

  /*close(0);
char arr[1024];
int fd=open(LOG,O_RDONLY);
scanf("%s",arr);
printf("%s",arr);
*/




 /* close(1);
 int fd=open(LOG,O_WRONLY,O_CREAT,O_TRUNC,0666);
printf("You can see me!!!\n"); 
printf("You can see me!!!\n"); 
printf("You can see me!!!\n"); 
printf("You can see me!!!\n"); 
fprintf(stdout,"stdout->You can see me!!!\n");
*/











 // close(0);
 // close(2);
/*int fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("%d\n",fd);

 fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("%d\n",fd);

 fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("%d\n",fd);

 fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("%d\n",fd);
close(2);
 fd=open(LOG,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("%d\n",fd);
*/

  return 0;
}
